# coding:utf-8

class Stack(object):
    def __init__(self):
        self.stack = []
        self.top = 0  # 初始化栈顶为0

    def push(self, data):  # 入栈
        i = 0
        lenth = len(data)
        for i in range(lenth):
            self.stack.append(data[i])
            self.top += 1  # 栈顶指针后移一个位置
        print("入栈后的栈顶位置:top->%d" % (self.top - 1))
        return self.stack

    def pop(self, stack):  # 出栈
        self.top = len(stack) - 1
        k = self.top
        for i in range(k + 1):
            print("top->%d:%s" % (self.top, stack[self.top]))
            self.top -= 1


data = []
lenth = input("请输入data的长度:")
for i in range(int(lenth)):
    x = input()
    data.append(x)
print("data:%s" % data)
s = Stack()
stack = s.push(data)
print("stack:%s,lenth:%d" % (stack, len(stack)))
s.pop(stack)